<template>
	<view>
		<view class="top-box">
			<view class="topx">
				<image src="../../static/无头像.png" mode="" v-if='flag'></image>
				<!-- <image :src="count.avatarUrl" mode="" v-if='flag'> </image> -->
				<!-- <open-data type="userAvatarUrl" v-else='flag' class="asdc"></open-data> -->
				<image :src="list.png" mode="" v-else='flag'></image>
			</view>
			<button @click="shouquans()" v-if="flag">微信登陆</button>
			<view v-else='flag' class="conent"> {{list.name}}({{lists.text}}{{lists.test}})</view>
		</view>
		<view class="lie" @click="geren">
			<view class="ss">
				<image src="../../static/我的资料.png" mode=""></image>
				<view>个人资料</view>
			</view>
			<span>></span>
		</view>

		<view class="lie" @click="$router('/pages/my/duiwu', {})">
			<view class="ss">
				<image src="../../static/同步.png" mode=""></image>
				<view>我的队伍</view>
			</view>
			<span>></span>
		</view>

		<view class="lie" @click="$router('/pages/my/yao', {})">
			<view class="ss">
				<image src="../../static/奖牌.png" mode=""></image>
				<view>邀请好友 </view>
			</view>
			<span>></span>
		</view>
		<view class="lie" @click="pai">
			<view class="ss">
				<image src="../../static/奖杯.png" mode=""></image>
				<view>排行榜</view>
			</view>
			<span>></span>
		</view>
		<navigator url="/pages/my/riqi">
			<view class="lie">
				<view class="ss">
					<image src="../../static/日历.png" mode=""></image>
					<view>新闻资讯</view>
				</view>
				<span>></span>
			</view>
		</navigator>

		<navigator url="/pages/my/shouqaun">
			<view class="lie">
				<view class="ss">
					<image src="../../static/授权.png" mode=""></image>
					<view>授权设置</view>
				</view>
				<span>></span>
			</view>
		</navigator>

		<navigator url="/pages/my/bu">
			<view class="lie">
				<view class="ss">
					<image src="../../static/步数.png" mode=""></image>
					<view>历史步数</view>
				</view>
				<span>></span>
			</view>
		</navigator>
		{{dataFromB}}
		<view class="lie">
			<view class="ss">
				<image src="../../static/版本号.png" mode=""></image>
				<view>版本号</view>
			</view>
			<span>202211.7 &nbsp; &nbsp; ></span>
		</view>
	</view>
</template>
<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import permission from '../../utils/permission.js'
	// import mixin from "@/pages/my/mixin"
	import utils from "@/utils";
	export default {
		// mixins: [mixin],
		data() {
			return {
				dataFromB: '',
				name: '',
				flag: true,
				list: {
					name: '',
					phone: "",
					sex: "",
					png: [""],
				},
				lists: {
					text: '',
					test: "",
				},
				// reFresh: "",
				// refreshIfNeeded: false,
			}
		},
		computed: {
			...mapState({
				counts: state => state.crad.counts
			})
		},
		onLoad() {
			// this.vvvvvvvvvvvvvvvv()
			// vuex console.log(this.$store.state.crad.count, "11111111111");
		},
		// watch: {
		// 	//监听reFresh,如果有修改就执行监听器
		// 	reFresh: function() {
		// 		//调接口刷新数据
		// 		this.vvvvvvvvvvvvvvvv()
		// 	}
		// },
		onShow() {
			this.vvvvvvvvvvvvvvvv();
			// let pages = getCurrentPages(); // 获取当前页面栈
			// let currentPage = pages[pages.length - 1]; // 当前页面
			// if (currentPage.data.refreshIfNeeded) {
			// 	currentPage.data.refreshIfNeeded = false;
			// 	this.vvvvvvvvvvvvvvvv(); // 调用列表重置刷新页面
			// 	setTimeout(function() {
			// 		uni.showToast({
			// 			icon: 'success',
			// 			title: "修改成功",
			// 		})
			// 	}, 300)
			// }
		},
		methods: {
			vvvvvvvvvvvvvvvv() {
				let that = this
				that.$api.cha().then((res) => {
					that.list = res.data[0]
					console.log('查', res);
				})
				that.$api.chadui().then((res) => {
					that.lists = res.data[0]
					console.log('查队', res);
				})
			},
			shouquans() { // this.getOk()
				// const isLogin = uni.getStorageSync("token");
				// if (isLogin) {
				let that = this
				uni.showModal({
					title: "获取你的用户信息",
					content: "获取你的昵称、头像",
					success(res) {
						if (res.confirm) {
							uni.getUserProfile({
								lang: 'zh_CN',
								desc: true,
								desc: '获取你的昵称、头像',
								success: (res) => {
									permission.getCode().then((res) => {
										// console.log('code', res.code)
										const code = res.code
										that.$api.wxLogin({
											code
										}).then((res) => {
											// console.log('res1111', res);
											uni.setStorageSync("token", res.data)
										})
									})
									that.$api.cha().then((res) => {
										console.log(
											'查询',
											res);
										that.list = res
											.data[0]
									})
									that.$api.chadui().then((res) => {
										that.lists = res
											.data[0]
										console.log(
											'查队',
											res);
									})
									uni.showToast({
										icon: 'loading',
										title: "授权中",
									})
									setTimeout(function() {
										that.flag = !that.flag;
									}, 1700)
									// that.name = res.userInfo
									// that.name.avatarUrl = "../../static/person2.jpg"
									// that.name.nickName = "瞿成功"
									// that.$store.commit('Minus', that.name)
								}
							})
						}
					}
				})

				// } else {
				// 	console.log("未登录")
				// }
			},
			da() {
				uni.switchTab({
					url: '/pages/dati/dati'
				})
			},
			geren() {
				this.$router('/pages/my/ge', {
					record: JSON.stringify(this.lists)
				}, )
				// uni.navigateTo({
				// 	url: '/pages/my/ge?record=' + JSON.stringify(this.lists)
				// })
			},
			pai() {
				this.$router('/pages/list/list', {}, "switchTab")
			},
			// sss() {
			// 	this.$api.cha().then((res) => {
			// 		console.log('res222222222', res);
			// 		this.list = res.data[0]
			// 	})

			// },
			// vv() {
			// 	//查询
			// 	this.$api.chadui().then((res) => {
			// 		this.lists = res.data[0]
			// 		console.log('res333333', res);
			// 		// console.log(this.lists);
			// 		// this.$store.commit('Minus', this.list)
			// 	})
			// },

		}
	}
</script>

<style scoped>
	.top-box {
		width: 100%;
		background-color: #f00;
		height: 300rpx;
		border-radius: 0px 0px 16px 16px;
	}

	.topx {
		width: 70px;
		height: 70px;
		border-radius: 50%;
		background-color: gainsboro;
		margin: 0 auto;
		/* padding-top: 10rpx; */
		box-sizing: border-box;
		background-image: url(../../static/无头像.png);
		background-size: 70px 70px;
		background-image: no-repeat;
	}

	.topx image {
		width: 70px;
		height: 70px;
		display: block;
		margin: 0 auto;
		border-radius: 50%;
	}

	.asdc {
		width: 70px;
		height: 70px;
		display: block;
		margin: 0 auto;
		border-radius: 50%;
	}

	button {
		border: none;
		background-color: #2dbe52;
		width: 33%;
		margin: 0 auto;
		height: 70rpx;
		line-height: 70rpx;
		margin-top: 15rpx;
		color: white;
		font-size: 15px;
	}

	.conent {
		color: white;
		text-align: center;
		margin: 0 auto;
		margin-top: 12px;
	}

	.lie {
		margin: 0 auto;
		margin-top: 20rpx;
		width: 90%;
		height: 70rpx;
		border-bottom: gray 1px solid;
		line-height: 70rpx;
		display: flex;
		justify-content: space-between;
	}

	.ss {
		width: 190rpx;
		display: flex;

	}

	.ss>view {
		color: black;
		font-weight: 600;
		margin-left: 20rpx;
	}

	.lie image {
		display: block;
		width: 20px;
		height: 20px;
		margin-top: 20rpx;
	}

	.lie span {
		display: block;

	}
</style>
